#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/binary_info.h"
#include "hardware/spi.h"

#include "wizchip_conf.h"
#include "w6100.h"
#include "w6100_spi.h"

static wiz_NetInfo static_net_info = {
    .mac = {0x00, 0x08, 0xdc, 0x16, 0xed, 0x2e},
    .ip = {192, 168, 1, 10},
    .sn = {255, 255, 255, 0},
    .gw = {192, 168, 1, 1},
    .dns = {8, 8, 8, 8},
    .ipmode = NETINFO_STATIC_V4};

wiz_NetInfo net_info;

int main()
{
    uint8_t temp;

    stdio_init_all();

    sleep_ms(2000);
    printf("W6100 network install example.\r\n");
    sleep_ms(2000);
    wizchip_initialize();
    /* Determine the network lock register status */
    if(!ctlwizchip(SYS_NET_LOCK, &temp))NETUNLOCK();

    wizchip_setnetinfo(&static_net_info);

    print_net_info(&net_info);
    
    sleep_ms(2000);
    while (true)
    {
        if(!wizphy_getphylink())printf("Please check the network cable connection.\r\n");
        else printf("Try ping the ip:%d.%d.%d.%d\r\n", net_info.ip[0], net_info.ip[1], net_info.ip[2], net_info.ip[3]);
        sleep_ms(1000);
    }
}
